<?php
/**
 * 节点模型类
 * @author zengnz
 *
 */
class NodeModel extends CommonModel
{
	protected $tableName = 'node';
	
	/**
	 * 获取所有节点
	 * @return array
	 */
	public function getAllNodes() {
		$nodeList = array();
		$allNodes = array();		
		$nodes = $this -> where('status=1') -> order('sort ASC') -> select();	
		if ($nodes) {
			foreach($nodes as $key => $val) {
				$allNodes[$val['pid']][$val['id']] = $val;
			}
			
			foreach ($allNodes[0] as $key => $val) {
				$nodeList[$val['id']] = array(
					'title' => $val['title'],
					'id' => $val['id'],
					'subNodes' => $allNodes[$val['id']]			
				); 
			}
		}
		
		return $nodeList;		
	}
	
	
}